User Preferenceを取得するサンプルコード。
User Preferenceはセキュリティ保護の対象であり、実行には
User Preferenceはセキュリティ保護の対象であり、実行には
import java.awt.Color; import java.awt.Font; import java.awt.Graphics; import javax.tv.xlet.Xlet; import javax.tv.xlet.XletContext; import org.dvb.ui.FontFactory; import org.dvb.user.GeneralPreference; import org.dvb.user.UserPreferenceManager; import org.havi.ui.HScene; import org.havi.ui.HSceneFactory; import org.havi.ui.HScreen; public class Main implements Xlet { public void initXlet(XletContext context){ try { HScene hs= HSceneFactory.getInstance().getFullScreenScene( HScreen.getDefaultHScreen().getDefaultHGraphicsDevice()); hs.setFont(f); hs.setVisible(true); // Preference Managerを取得 UserPreferenceManager mgr = UserPreferenceManager.getInstance(); Graphics g = hs.getGraphics(); g.setColor(Color.white); String[] keys = {"User Name", "User Language", "Parental Rating", "Country Code", "Default Font Size","User @"}; for( int i = 0; i < keys.length; i++ ){ // Preference取得用の箱を用意 GeneralPreference gp = new GeneralPreference(keys[i]); // Preferenceを取得 mgr.read(gp); // Preferenceの読み出し String s = gp.getMostFavourite(); if( null == s ) s = "NULL"; g.drawString(keys[i]+"="+s, 100, 100+100*i); } } catch (Throwable thr){ } } public void startXlet(){ } public void pauseXlet(){ } public void destroyXlet(boolean unconditional){}
}